package com.kx.yooli.kx.wechat.mapper.nplm;

import com.kx.yooli.kx.wechat.entity.nplm.NplmLoanContract;
import com.kx.yooli.kx.wechat.entity.nplm.NplmOvrdueCase;
import com.kx.yooli.kx.wechat.entity.nplm.OverdueCase;
import com.mybatisflex.annotation.UseDataSource;
import com.mybatisflex.core.BaseMapper;
import com.mybatisflex.core.query.QueryWrapper;

import java.util.List;

public interface OverdueCaseMapper extends BaseMapper<OverdueCase> {

    @UseDataSource("ds4")
    default List<OverdueCase> selectOverDuCaseByLoanNoPro(String loanNo){
        return selectListByQuery(QueryWrapper.create()
                .select(OverdueCase::getCertNo,OverdueCase::getCustName,
                        OverdueCase::getLoanNo,OverdueCase::getPlannedTotal,OverdueCase::getOnceSettleAmount,OverdueCase::getStatus,OverdueCase::getUpdateTime).select(NplmLoanContract::getLoanAmount)
                .from(OverdueCase.class).innerJoin(NplmLoanContract.class)
                .on(OverdueCase::getLoanNo,NplmLoanContract::getLoanNo)
                .where(OverdueCase::getLoanNo).eq(loanNo).orderBy(OverdueCase::getUpdateTime).desc().limit(1));
    };

}
